import request from '@/utils/request'

/**
 *
 * @param {data} 入参
 * @abstract 管理员增删改查接口
 */
export function addPromotionAjax(data) {
  return request({
    url: '/admin/rddPromotions',
    method: 'post',
    data: { ...data }
  })
}

export function updatePromotionAjax(data) {
  return request({
    url: '/admin/rddPromotions/' + data.id,
    method: 'put',
    data: { ...data }
  })
}

export function getPromotionAjax(data) {
    return request({
      url: '/admin/rddPromotions/' + data.id,
      method: 'get',
      params: { ...data }
    })
  }

export function fetchPromotionAjax(data) {
  return request({
    url: '/admin/rddPromotions',
    method: 'get',
    params: { ...data }
  })
}

export function delPromotionAjax(data) {
  return request({
    url: '/admin/rddPromotions/' + data.id,
    method: 'delete'
  })
}

export function getPromotionCodeAjax(data) {
  return request({
    url: '/admin/rddPromotions/' + data.id + '/rcCode',
    method: 'get'
  })
}

export function getPromotionUsersAjax(data, params) {
  return request({
    url: '/admin/rddPromotions/' + data.id + '/rcUsers',
    method: 'get',
    params: { ...params }
  })
}
